LOCALPATH=src
SRC_DIRS := $(shell find $(LOCALPATH) -maxdepth 4 -type d )
C_SRC_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
CPP_SRC_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
ALL_SRC_FILES = $(CPP_SRC_FILES) $(C_SRC_FILES)
MEDIAINC=-I${shell pwd}/inc -m32
OBJS = $(foreach n,$(ALL_SRC_FILES),$(addsuffix .o,$(basename ${n})))
DEMO = demo


all:$(OBJS) 
	@echo "link " $(DEMO)
	@cc $(OBJS) -o $(DEMO)  -lpthread -lm -lc -m32
clean:
	rm $(OBJS) -rf
	rm $(DEMO) -rf
%.o : %.c
	@echo "build " $@
	@$(CC) -g -O2 -fPIC -c -D_GNU_SOURCE $(MEDIAINC)  $< -o $@  -lm >/dev/null  $(PQ) \
                        $(CFLAGS)
%.o : %.cpp
	@echo "build " $@
	@$(CXX) -g -O2 -fPIC -c -D_GNU_SOURCE $(MEDIAINC)  $< -o $@  -lm >/dev/null  $(PQ) \
                        $(CFLAGS)
